<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" th:href="@{/res/css/amazeui.min.css}">
    <link rel="stylesheet" th:href="@{/res/css/admin.css}">
    <link rel="stylesheet" th:href="@{/res/css/app.css}">
    <script type="text/javascript" th:src="@{/js/jquery-1.11.3.min.js}"></script>

    <style>
        .admin-main {
            padding-top: 0px;
        }

        #btpass{
            position: relative;
            top:0px;
            left:25px;
        }

        #btdispass{
            position: relative;
            top:0px;
            left:75px;
        }
    </style>
</head>

<body>
<div class="am-cf admin-main">
    <!-- content start -->
    <!--<div class="admin-content">-->
        <div class="admin-content-body">
            <div class="am-g">
                <form class="am-form am-form-horizontal" action="role/addroleSubmit.action" method="post"
                      style="padding-top: 20px;">
                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label" id="label1">
                            账户名称
                        </label>
                        <div class="am-u-sm-9">
                            <input id="name" required="" placeholder="" value="" type="text" readonly="readonly">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label" id="label2">
                            账户余额
                        </label>
                        <div class="am-u-sm-9">
                            <input id="balance" required="" value="" type="text" readonly="readonly">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label" id="label3">
                            业务类型
                        </label>
                        <div class="am-u-sm-9">
                            <input id="type" required="" value="" type="text" readonly="readonly">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <label class="am-u-sm-3 am-form-label" id="label4">
                            交易金额
                        </label>
                        <div class="am-u-sm-9">
                            <input id="money" required="" value="" type="text" readonly="readonly">
                        </div>
                    </div>

                    <div class="am-form-group">
                        <div class="am-u-sm-9 am-u-sm-push-3">
                            <input class="am-btn am-btn-default am-btn-secondary" value="通过" type="button" onclick="pass()" id="btpass">
                            <input class="am-btn am-btn-default am-btn-secondary" value="不通过" type="button" onclick="dispass()" id="btdispass">
                        </div>
                    </div>
                </form>
            </div>
        </div>
    <!--</div>-->
</div>
</body>

<script>
    $(function () {
        //id从url得到
        var result=new Object();
        result=getParameter();
        var uName=result["uName"];
        var type=result["type"];
        var money=result["money"];
        document.getElementById("name").value=uName;
        document.getElementById("type").value=type;
        document.getElementById("money").value=money;
        $.ajax({
            type: 'post',
            url: '/wallet/selectByUname',
            data: {uName:uName},
            dataType: 'text',
            success: function (mydata) {
                document.getElementById("balance").value=mydata;
            },
            error: function () {
                alert("请求失败");
            }
        })
    })

    //解析url传值
    function getParameter() {
        var url=location.search;//获取url?后面的内容
        var result=new Object();
        if(url.indexOf("?")!= -1){
            var str=url.substr(1);
            strs=str.split("&");
            for(var i=0;i<strs.length;i++){
                result[strs[i].split("=")[0]]=decodeURIComponent(strs[i].split("=")[1]);
            }
        }
        return result;
    }

    //通过审核
    function pass() {
        //id从url得到
        var result=new Object();
        result=getParameter();
        var id=result["id"];
        var uName=result["uName"];
        var type=result["type"];
        var money=result["money"];
        var time=result["time"];
        var state="通过";
        $.ajax({
            type: 'post',
            url: '/finance/updateState',
            data: {id:id,uName:uName,type:type,money:money,time:time,state:state},
            dataType: 'text',
            success: function (mydata) {
                console.log(mydata);
            },
            error: function () {
                console.log("请求失败");
            }
        });
        close();
    }

    //不通过审核
    function dispass() {
        //id从url得到
        var result=new Object();
        result=getParameter();
        var id=result["id"];
        var uName=result["uName"];
        var type=result["type"];
        var money=result["money"];
        var time=result["time"];
        var state="不通过";
        $.ajax({
            type: 'post',
            url: '/finance/updateState',
            data: {id:id,uName:uName,type:type,money:money,time:time,state:state},
            dataType: 'text',
            success: function (mydata) {
                console.log(mydata);
            },
            error: function () {
                console.log("请求失败");
            }
        });
        close();
    }

    //返回上一页,并刷新
    function close() {
        window.parent.location.reload();
    }
</script>
</html>
